#include "pascaltriangle.h"

#include <iostream>

#include "computethread.h"

PascalTriangle::PascalTriangle()
    : power(3)
{
    prepareTriangle();
}

PascalTriangle::PascalTriangle(int power)
{
    this->power = power;
    prepareTriangle();
}

QVector<QVector<Digit> > &PascalTriangle::getTriangle()
{
    return triangle;
}

void PascalTriangle::print()
{
    std::cout << std::endl << "Postac trojkata Pascala:" << std::endl;

    for (int i = 0; i < triangle.size(); i++)
    {
        for (int j = 0; j < triangle[i].size(); j++)
        {
            std::cout << (*triangle[i][j].getDigit()) << " ";
            triangle[i][j].finish();
        }
        std::cout << std::endl;
    }
}

void PascalTriangle::prepareTriangle()
{
    triangle.resize(power);

    for (int i = 0; i < triangle.size(); i++)
    {
        triangle[i].resize(i+1);
    }
}
